﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GUI
{
    /// <summary>
    /// Interaction logic for ScriptNamerDialog.xaml
    /// </summary>
    public partial class ScriptNamerDialog : Window
    {
        //public bool done = false;

        public ScriptNamerDialog(Window owner)
        {
            Owner = owner;
            InitializeComponent();
            KeyDown += new KeyEventHandler(EnterPressed);
            Confirm.IsDefault = true;
            ScriptNameBox.Focus();
        }

        public ScriptNamerDialog(Window owner, string str)
            : this(owner)
        {
            ScriptNameBox.Text = str;
        }

        protected void Confirm_Click(object sender, RoutedEventArgs e)
        {
            //done = true;
            DialogResult = true;
            Close();
        }

        public String Return { get { return ScriptNameBox.Text.Replace(' ', '_').Replace('\t', '_');  } }

        private void EnterPressed(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
                Confirm_Click(null, null);
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
    }
}
